/* 
 * File:   coreSound.h
 * Author: Guillaume BAILLEUL
 *
 * Created on 4 avril 2011, 20:53
 */

#ifndef CORESOUND_H
#define	CORESOUND_H
#include "portaudio.h"
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>

using namespace std;

typedef float sample;

#define PA_SAMPLE_TYPE      paFloat32


class CoreSound
{
  private:
    PaStreamParameters inputParameters, outputParameters;

    //Error management
    PaError err;

    //Stream is a float
    PaStream *stream;

    //Statut of the instance
    bool is_initalized, is_running;

    //Audio Settings
    int sample_rate, frame_per_buffer;
    int nbr_in_channels, nbr_out_channels;
    int deviceIndex;
    


  public:
    CoreSound();
    ~CoreSound();
    int Start();
    int Stop();
    string* ListDevicesNames();
    int DevicesCount();
    void ChangeDevice(int);
    const PaDeviceInfo * GetDeviceInfo(int = -1);
    void SetSampleRate(int);
    void SetResolution(int);
};

//Functions
int callback( const void *, void *,
              unsigned long ,
              const PaStreamCallbackTimeInfo*,
              PaStreamCallbackFlags ,
              void *);

#endif	/* CORESOUND_H */

